package SEApp.dialogs
{
	import SEApp.se_util;
	
	import UIFree.controls.uif_gbutton;
	import UIFree.uif_component;
	import UIFree.uif_ecomponent;
	
	import flash.events.Event;
	import flash.geom.Rectangle;
	
	public class se_multyFriendDialog extends se_friendsDialog {
		public static var OKBUTTONCAPTION: String = 'Отправить'; 
		private var okButton: uif_gbutton;
		public function se_multyFriendDialog(parent:uif_component, canClose:int=1, a_classStyle:String='items') {
			super(parent, canClose, a_classStyle);
			area.multiselect = true;
		}
		
		override protected function createComponents(a_classStyle:String='items'):void {
			super.createComponents(a_classStyle);
			createButtons();
		}
		
		protected function createButtons(): void {
			var inner: Rectangle = getInner();
			inner.y = inner.y + listRect.height;
			var layer: uif_ecomponent = new uif_ecomponent(this, inner.x, inner.y, inner.width, inner.height);
			okButton = se_util.defButton(layer, layer.width / 2 - se_util.DEFWIDTHBUTTON, 0, OKBUTTONCAPTION, function(e: Event): void {
				if (doSelect != null) doSelect(area.selectList);
			}); 
			se_util.defButton(layer, layer.width / 2, 0, 'Отмена', doClose);
			
			okButton.disable = true;
		}

		override public function showSelect(a_selectFunc: Function): void {
			area.deselectAll();
			super.showSelect(a_selectFunc);
		}
		
		override protected function doSelectUser(e: Event): void {
			okButton.disable = area.selectList.length == 0;
			//if (_doSelect != null) _doSelect(_area.items[_area.selectIndex].object);
/*			if (_area.selectIndex > -1) {
				var user: Object = _area.items[_area.selectIndex].object;
				var userIndex: int = _selectUsers.indexOf(user);
				if (userIndex == -1) {
					selectUser(_area.selectIndex);
				} else {
					_selectUsers.splice(userIndex, 1);
					unSelectUser(userIndex);
				}
				okButton.disable = _selectUsers.length == 0;
			}*/
		}
/*		
		protected function selectUser(userIndex: int): void {
			_area.items[userIndex].control.style = _area.style['select'];
		};
		
		protected function unSelectUser(userIndex: int): void {
			_area.items[userIndex].control.style = _area.style['unselect'];
		};
*/		
		override protected function get listRect(): Rectangle {
			return getInner(0, 0, 0, -(se_util.DEFHEIGHTBUTTON + getSpace(true)));
		}
		
	}
}